package com.ppc.controller.worker;

import com.ppc.result.PageResult;
import com.ppc.result.Result;
import com.ppc.service.WorkerClaimService;
import com.ppc.vo.ClaimDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <<<<<<< HEAD
 *
 * @author jianKangS1 =======
 * @author Jeferry
 * @description: 工人申诉相关接口 >>>>>>> origin/st
 * @date 2023/12/20
 */
@Slf4j
@RestController
@Api(tags = "工人申诉接口")
public class WorkerClaimController {

  @Autowired
  private WorkerClaimService ClaimService;

  /**
   * 创建申诉
   *
   * @param taskId      任务id
   * @param claimType   申诉类型
   * @param claimReason 申诉原因
   * @return {@link Result}
   */
  @GetMapping("/worker/claim")
  @ApiOperation("创建申诉")
  public Result createClaim(Long taskId, Integer claimType,
      String claimReason) {   //调用service层来进行创建订单操作
    log.info("工人正在创建申诉");
    ClaimService.createClaim(taskId, claimType, claimReason);
    return Result.success();
  }

  /**
   * 查询申诉列表(根据状态)
   *
   * @param page        页码
   * @param pageSize    页大小
   * @param claimStatus 申诉状态
   * @return {@link Result}<{@link PageResult}>
   */
  @GetMapping("/worker/claim/list")
  @ApiOperation("查询申诉列表(根据状态)")
  public Result<PageResult> queryClaimList(Integer page, Integer pageSize, Integer claimStatus) {
    log.info("根据传入地状态查询申诉列表：{}", claimStatus);
    PageResult p = ClaimService.queryClaimList(page, pageSize, claimStatus);
    return Result.success(p);
  }

  /**
   * 查看申诉详情
   *
   * @param claimId 申诉id
   * @return {@link Result}<{@link ClaimDetailVO}>
   */
  @GetMapping("/worker/claim/detail")
  @ApiOperation("查看申诉详情")
  public Result<ClaimDetailVO> queryClaimDetail(Long claimId) {
    log.info("查看申诉详情");
    ClaimDetailVO claim = ClaimService.queryClaimDetail(claimId);
    return Result.success(claim);
  }

  /**
   * 获取申诉消息
   *
   * @param page     页码
   * @param pageSize 页大小
   * @return {@link Result}<{@link PageResult}>
   */
  @GetMapping("/worker/claim/message")
  @ApiOperation("获取申诉消息")
  public Result<PageResult> getClaimMessage(Integer page, Integer pageSize) {
    log.info("根据订单状态分页查询订单");
    PageResult p = ClaimService.getClaimMessage(page, pageSize);
    return Result.success(p);
  }

}
